source /etc/profile
if [ -n "$1" ]
then
do_date=$1
else
do_date=`date -d "-1 day" +%F`
sql="
with tmp1 as (
    select 
    orderId,`totalMoney`,
    from_unixtime(unix_timestamp(payTime, 'yyyy-MM-dd HH:mm:ss'), 'yyyy-MM-dd') paytime
    from dwd.dwd_trade_orders
    where dt >='2019-12-15' and dt <= '2021-1-15' and end_date='9999-12-31'  and payTime>='2020-01-01' and payTime<='2020-12-31'
)
    insert overwrite table dws.dws_trade_order_2020
    select orderID, totalMoney, paytime,  quarter(paytime), month(paytime), dayofweek(paytime), parse_holiday(paytime) from tmp1
"
hive -e "$sql"